package org.jeecg.modules.zcgl.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 租金支付方式
 */
@Getter
@AllArgsConstructor
public enum ModeOfPaymentTypeEnum {

//    PAY_DAY (1, "一天"),
    PAY_MONTHLY (10, "个月"),
    PAY_QUARTERLY(20,"季度"),
    PAY_HALF_YEAR(30,"半年"),
    PAY_YEAR(40,"一年");

    int status;
    String name;

    public static String getName(Integer status){
        if (status == null){
            return null;
        }
        for (ModeOfPaymentTypeEnum mode : ModeOfPaymentTypeEnum.values()){
            if (mode.getStatus() == status.intValue()) {
                return mode.name;
            }
        }
        return null;
    }

    /**
     * 支付方式计算月的数量
     * @param modeOfPayment
     * @return
     */
    public static int getMonth(Integer modeOfPayment){
        int m = 3;
        if (modeOfPayment == null) {
        } else if (modeOfPayment.compareTo(ModeOfPaymentTypeEnum.PAY_MONTHLY.getStatus()) == 0) {
            m = 1;
        } else if (modeOfPayment.compareTo(ModeOfPaymentTypeEnum.PAY_QUARTERLY.getStatus()) == 0) {
            m = 3;
        } else if (modeOfPayment.compareTo(ModeOfPaymentTypeEnum.PAY_HALF_YEAR.getStatus()) == 0) {
            m = 6;
        } else if (modeOfPayment.compareTo(ModeOfPaymentTypeEnum.PAY_YEAR.getStatus()) == 0) {
            m = 12;
        }
        return m;
    }
}
